package main

import "fmt"

func main() {
	arr := make([]int, 100)
	for i := 0; i < 100; i++ {
		arr[i] = i
	}
	s := [2]int{}
	for i := 0; i < 2; i++ {
		s[i] = i
	}
	/*	l1 := buildNode([]int{0})
		l2 := buildNode([]int{0})
		r := addTwoNumbers(l1, l2)
		printNode(r)*/

}
func addTwoNumbers(l1 *ListNode, l2 *ListNode) *ListNode {
	pre := &ListNode{}
	hp(pre, l1, l2, 0)
	return pre.Next
}
func hp(pre *ListNode, l1 *ListNode, l2 *ListNode, c int) {
	if l1 == nil && l2 == nil && c == 0 {
		return
	}
	newNode := &ListNode{}
	pre.Next = newNode
	sum := c
	if l1 != nil {
		sum += l1.Val
		l1 = l1.Next
	}
	if l2 != nil {
		sum += l2.Val
		l2 = l2.Next
	}
	c = sum / 10
	newNode.Val = sum % 10
	hp(pre.Next, l1, l2, c)
}
func buildNode(arr []int) *ListNode {
	root := ListNode{}
	curr := &root
	for i := 0; i < len(arr); i++ {
		curr.Val = arr[i]
		if i < len(arr)-1 {
			curr.Next = &ListNode{}
			curr = curr.Next
		}

	}
	return &root
}
func printNode(n *ListNode) {
	fmt.Print(n.Val)
	if n.Next != nil {
		printNode(n.Next)
	}
}

type ListNode struct {
	Val  int
	Next *ListNode
}
